import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;

import javax.swing.JPanel;

/**
 *
 * @author Bora SAYINER
 * @since Dec 21, 2014 10:41:55 AM
 * @version 1.0
 */
public class ShapePanel extends JPanel {

	private ArrayList<Drawable> drawables;

	public ShapePanel() {
		this.drawables = new ArrayList<Drawable>();
		setBackground(Color.DARK_GRAY);
	}

	public void addShape(Drawable drawable) {
		drawables.add(drawable);
		repaint();
	}

	public void removeShape() {
		drawables.remove(drawables.size() - 1);
		repaint();
	}

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		for (Drawable drawable : drawables) {
			drawable.draw((Graphics2D) g);
		}
	}

}
